﻿using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Write.API.Appcation.Commands.HospitalCommand;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HospitalZController : ControllerBase
    {
        private readonly IMediator mediator;

        public HospitalZController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 医院新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> HospitalCreate(HospitalCreateCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 医院删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> HospitalDelete(HospitalDeleteCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 医院修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> HospitalUpdate(HospitalUpdateCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

       
    }
}
